package com.syni.mdd.yhd.common.all.controller.protect;

import com.syni.mdd.sjb.common.component.utils.common.annotations.CheckParams;
import com.syni.mdd.yhd.common.all.dto.requestDto.BaseReDto;
import com.syni.mdd.yhd.common.all.service.BmsMarketActivityService;
import com.syni.mdd.yhd.common.all.service.MtHdAppLoginService;
import com.syni.mdd.yhd.common.all.service.MtHdAppUserLoginService;
import com.syni.mdd.sjb.common.component.utils.common.utils.ParamsMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @className BmsMarketingController
 * @description 商户端营销工具跳转
 * @Author cfx
 * @DATE 2019/6/25 10:15
 * @VERSION 1.0
 **/
@RestController
@RequestMapping("/marketing")
public class BmsMarketingController {
    @Autowired
    MtHdAppLoginService mtHdAppLoginService;

    @Autowired
    MtHdAppUserLoginService mtHdAppUserLoginService;

    @Autowired
    BmsMarketActivityService bmsMarketActivityService;

    @PostMapping("/enterMarketing")
    @CheckParams(checkAuth = true)
    public Map<String,Object> enterMarketing(@RequestBody Map<String,Object> paramsMap){
        String userIdentify = paramsMap.get("userIdentify").toString();
        Integer userId = Integer.parseInt(userIdentify);
        return mtHdAppLoginService.createRecord(userId);
    }


    @PostMapping("/userEnterMarketing")
    @CheckParams(checkAuth = true)
    public Map<String,Object> userEnterMarketing(@RequestBody Map<String,Object> paramsMap){
        String userIdentify = paramsMap.get("userIdentify").toString();
        Integer userId = Integer.parseInt(userIdentify);
        return mtHdAppUserLoginService.createRecord(userId);
    }

    @PostMapping("/findActivity")
    public Map<String,Object> findActivity(@RequestBody BaseReDto baseReDto){
        return bmsMarketActivityService.findActivity(baseReDto);
    }


    @PostMapping("/activityList")
    @CheckParams(checkAuth = true)
    public Map<String,Object> activityList(@RequestBody ParamsMap paramsMap){
        return bmsMarketActivityService.activityList(paramsMap);
    }
}
